<?php
/**
* $Id: edit_banmian.php 171 2010-10-22 09:04:17Z bwanglei@gmail.com $
*/

include_once(TEMP_ROOT_PATH.'/header.php');
?>
<div id="content">
	<div id="main">
		选择要修改的版面：<select onchange='document.location.href=this.options[this.selectedIndex].value;'>
		<option value="<?php echo $_SERVER['PHP_SELF'];?>">选择版面</option>
		<?php
		foreach ($banmians as $banmian) {
			?>
			<option value=""> -= <?php echo $banmian['name'];?> =- </option>
			<?php
			foreach ($banmian['banmians'] as $row_b) {
				?>
				<option <?php if (isset($_GET['bid']) && $_GET['bid']==$row_b['id']) echo 'selected';?> value="<?php echo apf_full_url('bid',$row_b['id'],'bid');?>"><?php echo $row_b['name'];?></option>
				<?php
			}
		}?></select>

		<!-- 显示此版面的线索和帖子 -->
		<?php
		if (isset($_GET['bid'])) {
			?>
			<div class="width_full"><table border="1" class="width_full"><form action="<?php echo apf_full_url();?>" method="post">
			<tr class="font_bold"><td></td><td>线索ID</td><td>标题</td><td>阅读次数</td><td>发表时间</td><td>作者</td><td>置顶</td><td>精华</td><td>删除</td></tr>
			<?php
			// 遍历所有线索主题
			foreach ($threads_articles as $thread_article) {
				?>
				<tr><td id="<?php echo $thread_article['id'];?>_show">
					<a href="javascript:;" onclick="show_hidden_articles_thread(<?php echo $thread_article['id'];?>);"><label id="<?php echo $thread_article['id'];?>_show_add" >+</label></a></td>
				<td><?php echo $thread_article['id'];?></td>
				<td><a href="javascript:;" onclick="show_hidden_articles_thread(<?php echo $thread_article['id'];?>);"><?php echo $thread_article['title'];?></a></td>
				<td><?php echo $thread_article['count_read'];?></td>
				<td><?php echo date('m-d Y年',$thread_article['article_time_date']);?></td>
				<td><?php echo $thread_article['username'];?></td>
				<!-- 是否置顶复选框 -->
				<td><?php
					if ($thread_article['is_top']==0) {
						?>
						<input type="checkbox" name="is_top_checkbox[]" value="<?php echo $thread_article['id'];?>" />
						<?php
					} else if ($thread_article['is_top']==1) {
						?>
						<input type="checkbox" name="is_top_checkbox[]" value="<?php echo $thread_article['id'];?>" checked />
						<?php
					}
				?></td>
				<!-- 是否加精复选框 -->
				<td><?php
					if ($thread_article['is_jing']==0) {
						?>
						<input type="checkbox" name="is_jing_checkbox[]" value="<?php echo $thread_article['id'];?>" />
						<?php
					} else if ($thread_article['is_jing']==1) {
						?>
						<input type="checkbox" name="is_jing_checkbox[]" value="<?php echo $thread_article['id'];?>" checked />
						<input type="hidden" name="old_jing[]" value="<?php echo $thread_article['id'];?>" />
						<?php
					}?>
				</td>
				<td><input type="checkbox" name="del[]" value="<?php echo $thread_article['id'];?>" /></td></tr>
				<?php
				if (isset($thread_article['articles']) && !empty($thread_article['articles'])) {
					// 遍历某个主题下的帖子
					?>
					<tr style="display:none;" name="<?php echo $thread_article['id'];?>_thread">
						<td colspan="9" align="center">当前主题下的帖子</td>
					</tr>
					<tr style="display:none;" name="<?php echo $thread_article['id'];?>_thread">
						<td></td><td>线索ID</td><td>作者</td><td colspan="2">内容摘要</td><td>帖子ID</td>
						<td>发表时间</td><td colspan="2" align="right">删除</td>
					</tr>
					<?php
					foreach ($thread_article['articles'] as $a_thread) {
						?>
						<tr style="display:none;" name="<?php echo $a_thread['thread_id'];?>_thread"><td></td>
						<td><?php echo $a_thread['thread_id'];?></td><td><?php echo $a_thread['username'];?></td>
						<td colspan="2"><?php echo apf_toFixLen($a_thread['content'],28);?></td>
						<td><?php echo $a_thread['id'];?></td><td><?php echo date('m-d Y年',$a_thread['time_date']);?></td>
						<td></td><td><input type="checkbox" name="del_articles[]" value="<?php echo $a_thread['id'];?>" /></td></tr>
						<?php
					}
					?>
					<tr style="display:none;" name="<?php echo $thread_article['id'];?>_thread">
						<td colspan="9" align="center">-----</td>
					</tr>
					<?php
				}
			}?>
			<tr class="font_bold"><td></td><td>ID</td><td>标题</td><td>阅读次数</td><td>发表时间</td><td>作者</td><td>置顶</td><td>精华</td><td>删除</td></tr>
			<tr class="align_right"><td colspan="9"><input type="submit" value="提交修改" /></td></tr>
			</form></table></div>
			<?php
		}?>
	</div>
	<?php include_once(TEMP_ROOT_PATH.'/sidebar.php');?>
</div>
<?php include_once(TEMP_ROOT_PATH.'/footer.php');?>
